import {
    center,
    right,
    grid,
    input,
    header,
    button,
    search,
} from '@/css/VueCss.module.scss' ;
export default {
    title: '合同列表',
    order: 1,
    items: [{
        region: 'center',
        class: center,
        layout: 'vertical',
        items: [{
            items: [{
                id: 'search',
                class: search,
                widget: 'search-datesearch',
                times: [{
                    label: '今日',
                    value: 'today'
                }, {
                    label: '昨日',
                    value: 'yesterday'
                },{
                    label: '近7日',
                    value: 'lately7'
                },{
                    label: '近30日',
                    value: 'lately30'
                }],
                rangeTimes: false,
                selects: [{
                    field: 'category_uuid',
                    placeholder: '请选择合同类型',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_contract_category',
                        },
                    },
                },{
                    field: 'status_uuid',
                    placeholder: '请选择合同状态',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_contract_status',
                        },
                    },
                }],
                text:{
                    field: 'keywords',
                    placeholder: '请输入合同名称'
                },
                onSearch: [{
                    action:'grid-load',
                    target:'$widgets.grid',
                    params:'$params'
                }]
            }, {
                class: header,
                layout: 'horizontal',
                items: [{
                    class: button,
                    widget: 'button',
                    value: '新增',
                    onClick: [{
                        action:'dialog-show',
                        path:'Contract/Edit',
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }],
                        cancelActions:[{
                            action:'print',
                            description:'取消对话框'
                        }]
                    }]
                }, {
                    class: button,
                    widget: 'button',
                    value: '删除',
                    onClick:[{
                        action:'confirm',
                        title:'删除数据',
                        message:'是否删除勾选数据?',
                        confirm:[{
                            var:'checkedItemIds',
                            action:'array-value',
                            target:'$widgets.grid.checkedItems',
                            key:'id'
                        },{
                            action:'print',
                            description:'列表勾选项',
                            value:'$vars.checkedItemIds'
                        },{
                            action:'service',
                            path: 'crm/contract/allremove',
                            params:{
                                id:'$vars.checkedItemIds'
                            }
                        },{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }]
                    }]
                },{
                    class: button,
                    widget: 'basic-groupbutton',
                    value: '删除',
                    onClick: [{
                        action: 'dialog-show',
                        path: 'grid/item/detail/Drawer',
                        params: {
                            value: '`第 ${$view.count ++} 次点击`'
                        }
                    }]
                }]
            }]
        },{
            id:'grid',
            class: grid,
            widget:'grid',
            service: 'crm/contract/list',
            pageSize:20,
            columns:[{
                prop:'code',
                label:'合同编号',
                minWidth: 150
            },{
                prop:'name',
                label:'合同名称',
                minWidth: 150
            },{
                prop:'customer_uuid',
                label:'客户(公司)',
                dictionary: 'common/dictionary/customer',
                minWidth: 150
            },{
                prop:'category_uuid',
                label:'合同类型',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_contract_category',
                    },
                },
                width: 130
            },{
                prop:'status_uuid',
                label:'合同状态',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_contract_status',
                    },
                },
                width: 130
            },{
                prop:'sign_time',
                label:'签订时间',
                width: 180
            },{
                prop:'remarks',
                label:'备注',
                minWidth: 150
            }],
            buttons:[{
                value:'编辑',
                onClick:[{
                    action:'dialog-show',
                    path:'Contract/Edit',
                    params: '$params',
                    applyActions: [{
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'reload'
                    }],
                    cancelActions:[{
                        action:'print',
                        description:'取消对话框'
                    }]
                }]
            },{
                value:'详情',
                onClick:[{
                    action:'dialog-show',
                    path:'Contract/Details',
                    params: '$params',
                }]
            },{
                value:'删除',
                type:'danger',
                onClick:[{
                    action:'confirm',
                    title:'删除数据',
                    message:'是否删除该条数据?',
                    confirm:[{
                        action:'service',
                        path:'crm/contract/remove',
                        params: {
                            id:'$params.id'
                        }
                    },{
                        action:'call',
                        target:'$widget',
                        method:'reload'
                    }]
                }]
            }],
            flex:true,
            operationWidth:130,
            operationButtonCount:3,
            enableCheckboxColumn:true,
        }]
    }]
} ;
